
**********************************************************************************************
* Replication file: "Insiders, outsiders, skills and preferences for social protection: evidence from a survey experiment in Argentina"
* Irene Menéndez González, January 2021
**********************************************************************************************

clear
set more off

use lapopdata.dta, clear
 
gen countryID=.
replace countryID=pais

label define country 17 "ARG" 10 "BOL" 15 "BRA" 13 "CHL" 8 "COL" 6 "CRI" 9 "ECU" ///
3 "ELS" 2 "GTM" 4 "HND" 1 "MEX" 7 "PAN" 12 "PAR" 11 "PER" 21 "RDO" ///
14 "URY" 16 "VEN" 22"HIT" 23 "JAM" 24 "GUY" 25"TTO" 26 "BLZ" 27"SUR" 5"NIC" 28"BHS" 29"BRB" 40"USA" 41"CAN" ///
30"GRD" 31"LCA" 32"DMA" 33"ATG" 34"VCT" 35"KNA", modify
label values countryID country
tab countryID

* Drop US and CAN
drop if countryID==40
drop if countryID==41



* Generate variables
*********************************************

* DV Targeted redistribution - El gobierno debe gastar más en ayudar a los pobres. ¿Hasta qué punto está de acuerdo o en desacuerdo con esta frase?

tab redist1
gen redistpoor=.
replace redistpoor=1 if redist1==1
replace redistpoor=2 if redist1==2
replace redistpoor=3 if redist1==3
replace redistpoor=4 if redist1==4
replace redistpoor=5 if redist1==5
replace redistpoor=6 if redist1==6
replace redistpoor=7 if redist1==7

label define redistp 1 "Strongly Disagree" 7 "Strongly Agree"
label values redistpoor redistp

* Indep Variables

* Insiders

* Insiders are public and private employees that make social security contributions. Formal se-flemployed are coded, but excluded in analysis for consistency with experimental analysis. 
* Formal: "For this job, do you or your employer make contributions to the social security/pension system?" 

gen insider=.
replace insider=2 if ocup1a==1 // public sector workers
replace insider=2 if formal==1 & ocup1a==2 // private sector workers making contributions
replace insider=1 if formal==1 & ocup1a==3 // shareholder making contributions
replace insider=1 if formal==1 & ocup1a==4 // self-employed making contributions
replace insider=0 if formal==2 & ocup1a==2  // private sector workers that don't make contributions
replace insider=0 if formal==2 & ocup1a==3  // shareholders that don't make contributions
replace insider=0 if formal==2 & ocup1a==4  // self-employed that don't make contributions
replace insider=0 if formal==2 & ocup1a==5  // unpaid workers

lab def e 0 "Outsider" 1 "Formal self-employed" 2 "Insider"
lab val insider e
lab var insider "Insider" 


* Skill level

*code individuals according to whether they more or less skilled than the median level in country.

gen edu_p50 = 0 if ed ! = .

foreach v of numlist 1/23 {
sum ed if countryID == `v', d
    qui replace  edu_p50 = 1 if ed < r(p50) & countryID == `v'
}

label variable edu_p50 "Low-skilled"


* Measure of insiders and outsiders, by skill level

gen grouplsi=.
replace grouplsi=0 if insider==2 & edu_p50==0 // High-skill insider
replace grouplsi=1 if insider==2 & edu_p50==1 // Low-skill insider
replace grouplsi=2 if insider==0 & edu_p50==0 // High-skill outsider
replace grouplsi=3 if insider==0 & edu_p50==1 // Low-skill outsider

lab def gr 0 "High-skill insider" 1 "Low-skill insider" 2 "High-skill outsider" 3 "Low-skill outsider"
lab val grouplsi gr
lab var grouplsi "Low- and high-skill insiders and outsiders"


* Controls 
*******************************

recode q1 (1=0) (2=1) (else=.)
gen woman=q1

gen age=ln(q2)
replace age=. if age>99

* Size of place: 1=capital nacional, 2=ciudad grande, 3=ciudad mediana, 4=ciudad pequeña, 5=area rural
recode tamano 1=5 2=4 3=3 4=2 5=1

gen income=.
replace income=q10new

label variable tamano "Urbanicity"
label variable age "Age (logged)"
label variable woman "Woman"
label variable income "Household income"


* Regression models
*************************************	

* Table A6. Effect of skill level on support for redistribution to the poor, among (i) labor market insiders and (ii) insiders and outsiders, for 16 Latin American countries, 2018.

* Model 1
reg redistpoor edu_p50 if insider==2, vce(cluster countryID)
* Model 2
reg redistpoor edu_p50 woman age tamano if insider==2, vce(cluster countryID)
* Model 3
reg redistpoor edu_p50 woman age tamano i.countryID if insider==2, vce(cluster countryID) 
* Model 4
reg redistpoor i.insider##i.edu_p50 if insider!=1, vce(cluster countryID)
* Model 5
reg redistpoor i.insider##i.edu_p50 woman age tamano if insider!=1, vce(cluster countryID)
* Model 6
reg redistpoor i.insider##i.edu_p50 woman age tamano i.countryID if insider!=1, vce(cluster countryID)

	
* Table A7: Effect of labor-market group, defined on the basis of skill level and labor-market status, on support for redistribution to the poor, for 16 Latin American countries, 2018.
* This is mathematically equivalent to models 4-6 in Table A6, but is used to compute mean predicted values of support for redistribution depicted in Figure 4.

* Model 1
reg redistpoor i.grouplsi if insider!=1, vce(cluster countryID)
* Model 2
reg redistpoor i.grouplsi woman age tamano if insider!=1, vce(cluster countryID)
* Model 3
reg redistpoor i.grouplsi woman age tamano i.countryID if insider!=1, vce(cluster countryID)

	
* Figure 4: Average predicted values for redistribution to the poor, among low- and high-skilled insiders and outsiders, in 16 Latin American countries for 2018. Based on model 3 in Table A7. 

reg redistpoor i.grouplsi woman age tamano i.countryID if insider!=1, vce(cluster countryID)
margins grouplsi
margins grouplsi, coeflegend post 
marginsplot, recast(bar) plotopts(barwidth(.7)) ///
	title("") ///
	ytitle("Predicted values for support for redistribution to the poor", margin(small)) ///
	xtitle("") ylabel(, nogrid labsize(small)) yticks(none) ///
	graphregion(color(white) lcolor(white)) 


* Exporting findings 
********************************

* Table A6

reg redistpoor edu_p50 if insider==2, vce(cluster countryID)
outreg2 using resultsA6, word replace ctitle(Model 1) dec(3) label 

reg redistpoor edu_p50 woman age tamano if insider==2, vce(cluster countryID)
outreg2 using resultsA6, word append ctitle(Model 2) dec(3) label 

reg redistpoor edu_p50 woman age tamano i.countryID if insider==2, vce(cluster countryID) 
outreg2 using resultsA6, word append ctitle(Model 3) dec(3) label

reg redistpoor i.insider##i.edu_p50 if insider!=1, vce(cluster countryID)
outreg2 using resultsA6, word append ctitle(Model 4) dec(3) label

reg redistpoor i.insider##i.edu_p50 woman age tamano if insider!=1, vce(cluster countryID)
outreg2 using resultsA6, word append ctitle(Model 5) dec(3) label 

reg redistpoor i.insider##i.edu_p50 woman age tamano i.countryID if insider!=1, vce(cluster countryID)
outreg2 using resultsA6, word append ctitle(Model 6) dec(3) label

* Table A7

reg redistpoor i.grouplsi if insider!=1, vce(cluster countryID)
outreg2 using resultsA7, word append ctitle(Model 2) dec(3) label 

reg redistpoor i.grouplsi woman age tamano if insider!=1, vce(cluster countryID)
outreg2 using resultsA7, word append ctitle(Model 2) dec(3) label

reg redistpoor i.grouplsi woman age tamano i.countryID if insider!=1, vce(cluster countryID)
outreg2 using resultsA7, word append ctitle(Model 3) dec(3) label












	
	
	
